<tagLib name="strends" />
<include file="Public:header" />
<link href="./Tpl/Default/Static/Css/basic.css" rel="stylesheet">
<link href="./Tpl/Default/Static/Css/dropzone.css" rel="stylesheet">
<script type="text/javascript" src="./Tpl/Default/Static/Js/dropzone.js"></script>
<script type="text/javascript" src="./Tpl/Default/Static/Js/jquery-ui.min.js"></script>
<script type="text/javascript" src="./Tpl/Default/Static/Js/idrag.js"></script>
<style type="text/css">
	.tags_ul li{
		float:left;
		margin: 5px 0 0 5px;
		padding: 5px 5px 4px 5px;
		white-space: nowrap;
	}
</style>
<script type="text/javascript">
    Dropzone.options.dropzoneForm = {
        url: "/trends/index.php?m=Active&a=uploadpic&albumid={$albumid}",
		acceptedFiles: "image/*",
		addRemoveLinks: true,
		paramName:"filedatas",
		thumbnailWidth:"200",
		thumbnailHeight:"200",
		init: function () {
            this.on("complete", function (data) {  
				//var res = eval('(' + data.xhr.responseText + ')');
                //alert(res.Message);
            });
			this.on("success", function(file, response) {
				var obj = eval( "(" + response + ")" );
				file.serverId = obj.shareid; 
				file.albumid = obj.albumid; 
				var div = document.createElement("div");
	
				div.innerHTML = "<span class='sharepic' data='"+obj.shareid+"'></span>";
				file.previewTemplate.appendChild(div);
			 });
			 this.on("removedfile", function(file) {
				  if (!file.serverId) { return; } 
				  $.post("/trends/index.php?m=Active&a=delpic&albumid="+file.albumid+"&shareid=" + file.serverId); 
			 });
        }
    };
	function delpic(pcid,albumid){
		$.post("/trends/index.php?m=Active&a=delpic&albumid="+albumid+"&shareid=" + pcid); 
		$('.delpic_'+pcid).parent().remove();
	}
	$(function(){
		$('.submit_btn').click(function(){
			var _length = $('.sharepic').length;
			if(_length>0){
				var _aidArray = [];
				var _pnameArray = [];
				var _textareaArray = [];
				var _sortArray = [];
				for(var j=0;j<_length;j++)
				{
					var _aid = $(".sharepic:eq("+j+")").attr("data");
					var _pname = $(".img-desc:eq("+j+")").val();
					var _share_content = $(".dz-content:eq("+j+")").val();
					var _sort = $(".sharepic:eq("+j+")").attr("title");
					_aidArray[j] = _aid;
					_pnameArray[j] = _pname;
					_textareaArray[j] = _share_content;
					_sortArray[j] = _sort;
				}
			}
			var query = new Object();
			query.aidArray = _aidArray;
			query.contentArray = _textareaArray;
			query.pnameArray = _pnameArray;
			query.sortArray = _sortArray;
			
			$.ajax({
					url: "/trends/index.php?m=Active&a=textedit",
					type: "POST",
					data:query,
					dataType: "json",
					success: function(result){
						if(result.status == 1){
							location.href="/trends/index.php?m=Active&a=index";
						}else{
							alert(result.message);
						}
					}
			});
		});
	});	
	
</script>
 <div id="maskLayer"></div>
<div class="handle-btns">
	<strends:linkBtn text="{%RETURN_LIST}" href="{:Cookie::get('returnUrl')}" />
</div>
<form method='post' class="dropzone" id="dropzoneForm" name="form" action="" enctype="multipart/form-data">
<volist name='share_list' id='v' key='k'>
<div class="dz-preview dz-processing dz-image-preview dz-success dz-complete">  
	<div class="dz-image">
		<img data-dz-thumbnail="" alt="" width="200" class="m_title" height="200" src="/res/{$v['index_img']}">
		<textarea class="img-desc" placeholder="图片导语">{$v['title']}</textarea>
		<textarea class="dz-content" placeholder="图片正文">{$v['content']}</textarea>
	</div>  
	<div class="dz-details" style="display:none;">    
		<div class="dz-size">
			<span data-dz-size=""></span>
		</div>    
		<div class="dz-filename">
			<span data-dz-name=""></span>
		</div>  
	</div>  
	<div class="dz-progress">
		<span class="dz-upload" data-dz-uploadprogress="" style="width: 100%;"></span>
	</div>  
	<div class="dz-error-message">
		<span data-dz-errormessage=""></span>
	</div>  
	<div class="dz-success-mark">    
	</div>  
	<div class="dz-error-mark"></div>
	<a class="dz-remove delpic_{$v['share_id']}" href="javascript:void(0);" onclick="delpic({$v['share_id']},{$albumid})" data-dz-remove="">删除</a>
	
	<div><span class="sharepic" data="{$v['share_id']}" title="{$v['sort']}"></span></div>
</div>
</volist>
</form>
<table>
	<tr class="act">
		<th>&nbsp;</th>
		<td>
			<input type="submit" class="submit_btn" value="{%SUBMIT}" />
			<input type="reset" class="reset_btn" value="{%RESET}" />
		</td>
	</tr>
</table>
<script>
	//设置遮罩层
    function maskLayout(){
        var maskobj = $("#maskLayer");
        var winH = $("body").height();
        maskobj.css({"display":"none","height":winH+"px"}).slideDown("slow");
    }
	/**封面图裁剪。
	*author:join
	*time：2014/7/1
	*/
	function indeximg(obj){
		$("#iframe").remove();
        maskLayout();
		var shareimg=$(obj).attr("img-value");
        var shareid=$(obj).attr("share-value");
        if(!shareid){
            alert("未获取到图片id值");
        }
		var albumid={$albumid};

		var css1 = "style='float:left;z-index:9999;position:absolute;top:100px;left:293px;'";
		var css2 = "style='float:right;width:60px;height:880px;background:#313131;text-align:center;line-height:50px;padding-top:320px;font-weight:bold;cursor:pointer;'";
		var css3 = "style='float:left;width:894px;height:auto;border:3px #313131 solid;background:#000;'";
		var iframe = "<iframe src='/trends/index.php?m=Active&a=makeImg&loc="+shareimg+"&shareid="+shareid+"&albumid="+albumid+"' width='900' height='900' scrolling='no' frameborder='1'></iframe>";
        $("body").before("<div id='iframe' "+css1+"><div id='leftbox' "+css2+"><font color='white'>点<br />击<br />关<br />闭</font></div><div id='rightbox' "+css3+"'>"+iframe+"</div></div>");
        var h=$("#rightbox").height();
        $("#iframe").css("top",50);
        $("#iframe").css("left",250);
        $("#leftbox").css("height",h-314+"px");
        $("#leftbox").click(function(){
            $("#iframe").remove();
            $("#maskLayer").css("display","none");
        });
	}
    
</script>
<include file="Public:footer" />